﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;

namespace Phone.Framework.Config
{
    public class SettingManager
    {
        Dictionary<string, object> settings = new Dictionary<string, object>();

        public T Get<T>(string key, T defaultValue)
        {
            Setting<T> setting = null;
            if (settings.ContainsKey(key))
                setting = (settings[key] as Setting<T>);
            else
            {
                setting = new Setting<T>(key, defaultValue);
                settings.Add(key, setting);
            }
            return setting.Value;
        }

        public void Set<T>(string key, T val)
        {
            Setting<T> setting = null;
            if (settings.ContainsKey(key))
                setting = (settings[key] as Setting<T>);

            setting.Value = val;
        }
    }
}
